***********PEPFAR PAPER REPLICATION***********
***************APRIL 2013, CGD****************

cd "N:\Health\Value for Money\Background Papers\PEPFAR\Replication"

*****************************************************************
***TABLE 1: PLANNED FUNDING BY TOP 25 RECIPIENT ORGANIZATIONS ***
*****************************************************************

use "agency-country-partner-fund-2008-1115unique", clear

** THIS DATASET HAS 1115 OBSERVATIONS UNIQUE AGENCY-COUNTRY-PARTNER OBSERVATIONS ** 

collapse (sum) fundamountadjusted, by(partnerinst countrytarg)
count
*1037
total(fundamountadjusted)
save agency-country-partner-fund-2008-1115unique-collapsedpartnercountry1037, replace
** THIS DATASET HAS 1037 OBSERVATIONS BY UNIQUE COUNTRY-PARTNERS

use agency-country-partner-fund-2008-1115unique-collapsedpartnercountry1037,clear
g countrycount = 1
collapse (sum) fundamountadjusted countrycount, by(partnerinst)
count
*477
total(fundamountadjusted)
save agency-country-partner-fund-2008-1115unique-collapsedpartnercountry1037-collapsepartner477, replace

********************************************************************************************
***TABLE 2: NUMBER OF RECIPIENTS OF PLANNED PEPFAR FUNDING BY IMPLEMENTING AGENCY, FY2008 **
********************************************************************************************

use agency-country-partner-fund-2008-1115unique.dta,clear
replace srcagency = "HHS" if srcagency == "CDC"
collapse (sum) fundamountadjusted, by(srcagency countrytarg)
g countrycount = 1
replace srcagency = "HHS" if srcagency == "CDC"
collapse (sum) fundamountadjusted countrycount, by(srcagency)
save total-mil.dta

use agency-country-partner-fund-2008-1115unique.dta,clear
replace srcagency = "HHS" if srcagency == "CDC"
collapse (median) fundamountadjusted, by(srcagency)
save median.dta

use agency-country-partner-fund-2008-1115unique.dta,clear
sort partnerinst
save, replace
total(fundamountadjusted)

***** MANUALLY LABEL 477 PARTNER ORGANIZATIONS BY TYPE IN EXCEL
/*
replace academic = 0 if academic == .
replace localgovt = 0 if localgovt == .
replace ngo = 0 if ngo == .
replace usg = 0 if usg == .
replace forprofit = 0 if forprofit == .
replace unbilateral = 0 if unbilateral == .
sort partnerinst
replace unbilateral = 1 if partnerinst == "Joint United Nations Programme on HIV/AIDS"
save partner-type-file.dta
*/

use agency-country-partner-fund-2008-1115unique.dta,clear
sort partnerinst
merge partnerinst using partner-type-file.dta
tab _merge
drop if _merge == 2
sort _merge
edit
replace ngo = 1 if partnerinst == "International Research and Exchange Board" | partnerinst == "Development Aid People to People" | partnerinst == "Share Mediciti"
replace unbilateral = 1 if partnerinst == "Chinese Center for Disease Prevention and Control"
replace academic = 0 if academic == .
replace localgovt = 0 if localgovt == .
replace ngo = 0 if ngo == .
replace usg = 0 if usg == .
replace forprofit = 0 if forprofit == .
replace unbilateral = 0 if unbilateral == .
g test = academic + localgovt + ngo + usg + forprofit + unbilateral
tab test
list if test == 0
drop _merge test
save agency-country-partner-fund-2008-1115unique-orgcat.dta, replace

use agency-country-partner-fund-2008-1115unique-orgcat.dta,clear
replace srcagency = "HHS" if srcagency == "CDC"
collapse (sum) fundamountadjusted, by(partnerinst srcagency academic localgovt ngo usg forprofit unbilateral)
count
*531
*collapse (sum) fundamountadjusted academic localgovt ngo usg forprofit unbilateral, by(srcagency)
count
*edit
g test = academic +localgovt +ngo +usg +forprofit +unbilateral
tab test
list if test == 0
drop test

use agency-country-partner-fund-2008-1115unique-orgcat.dta,clear
g test = academic +localgovt +ngo +usg +forprofit +unbilateral
drop if test == 0
drop if srcagency == "PEPFAR"
replace srcagency = "HHS" if srcagency == "CDC"
total(fundamountadjusted) 
total(fundamountadjusted) if academic == 1 
total(fundamountadjusted) if localgovt == 1 

collapse (sum) fundamountadjusted, by(partnerinst srcagency academic localgovt ngo usg forprofit unbilateral)
count
collapse (sum) fundamountadjusted academic localgovt ngo usg forprofit unbilateral, by(srcagency)
count
g total = academic +localgovt +ngo +usg +forprofit +unbilateral
edit
collapse (sum) fundamountadjusted academic localgovt ngo usg forprofit unbilateral
edit

use agency-country-partner-fund-2008-1115unique-orgcat.dta,clear
replace srcagency = "HHS" if srcagency == "CDC"
collapse (sum) fundamountadjusted, by(srcagency academic localgovt ngo usg forprofit unbilateral)
count

use agency-country-partner-fund-2008-1115unique-orgcat.dta,clear
replace srcagency = "HHS" if srcagency == "CDC"
collapse (sum) fundamountadjusted, by(partnerinst academic localgovt ngo usg forprofit unbilateral)
count
save agency-country-partner-fund-2008-1115unique-orgcat-collapsed.dta 

****************************************************************************
***TABLE 3: PEPFAR COUNTRIES ONLY: PREDICTORS OF PEPFAR FUNDING, 2004-11 ***
****************************************************************************

use "PEPFAR_outlays_crosscountry.dta"
keep if pepfar==1
reg pepfarout0411 p_unaids2002, r
reg pepfarout0411 focus, r
reg pepfarout0411 p_unaids2002 focus, r
reg pepfarout0411 totalhivgffunding, r
reg pepfarout0411 p_unaids2002 totalhivgffunding, r
reg pepfarout0411 ge2002, r
reg pepfarout0411 gdppercap2002, r
reg pepfarout0411 p_unaids2002 focus totalhivgffunding ge2002 gdppercap2002, r

